package org.budo.mongo.jdbc.driver.config;

import java.io.Serializable;

/**
 * 用以配置一些选项
 * 
 * @author lmw
 */
public class BudoMongoJdbcDriverConfig implements Serializable {
    private static final long serialVersionUID = 6079909430600455532L;

    /**
     * 默认new一个
     */
    private static BudoMongoJdbcDriverConfig INSTANCE = new BudoMongoJdbcDriverConfig();

    private Action whenSetNotAutoCommit = Action.WARN;

    /**
     * 再次new时会覆盖默认配置
     */
    public BudoMongoJdbcDriverConfig() {
        INSTANCE = this;
    }

    public static BudoMongoJdbcDriverConfig getInstance() {
        return INSTANCE;
    }

    public Action getWhenSetNotAutoCommit() {
        return this.whenSetNotAutoCommit;
    }

    /**
     * Connection 设置为不自动提交时的处理
     */
    public void setWhenSetNotAutoCommit(Action whenSetNotAutoCommit) {
        this.whenSetNotAutoCommit = whenSetNotAutoCommit;
    }

    public enum Action {
        /**
         * 忽略
         */
        IGNORE,

        /**
         * 日志警告
         */
        WARN,

        /**
         * 抛出异常
         */
        THROW
    }
}